package com.hangman;

import java.io.Serializable;

import android.util.Log;

@SuppressWarnings("serial")
public class Task implements Serializable{
	private char[] word;

	public Task(String chosenWord) {
		word = new char[chosenWord.length()];
		word = chosenWord.toCharArray();
	}

	public char getCharAt(int index) {
		if (-1 < index && index < word.length) {
			return word[index];
		}
		throw new IndexOutOfBoundsException();
	}

	public boolean checkIfContains(char letter) {
		for (int i = 0; i < word.length; i++) {		
			if (Character.toLowerCase(word[i]) == Character.toLowerCase(letter)) {
				return true;
			}
		}
		return false;
	}

	public int getWordLength() {
		return word.length;
	}

	public String toString() {
		String result = "";
		for (int i = 0; i < word.length; i++) {
			result += word[i];
		}
		return result;
	}
}
